function checkNotNull(){
				if($("#Name_firstleaveCity").val()=="" || $("#Name_firstleaveCity").val()=="全拼/简拼/汉字" || '中文/拼音'==$("#Name_firstleaveCity").val()){
     				$("#errorMessageCity").css({"display": ""});
     				$("#Name_firstleaveCity").addClass("onFormError");
  					var str="<p>入住城市不能为空。</p><div class=\"inArr\"></div>";
  					$("#errorContentCity").html(str);
  					
			 		return;
  				}else{
  					$("#Name_firstleaveCity").removeClass("onFormError");
  					$("#errorMessageCity").css({"display": "none"});
  				}
			 		
			 	var myDate = new Date(); 
			 	var st=$("#date").val().replace("-","/").replace("-","/");
  				var et=$("#enddate").val().replace("-","/").replace("-","/");
  
 				var sd=new Date(Date.parse(st));
  				var ed=new Date(Date.parse(et));
  				var nowdate=new Date();
				if($("#Name_firstleaveCity").val()=="香港特别行政区" || $("#Name_firstleaveCity").val()=="澳门特别行政区"){
			 		if (parseInt((sd-myDate)/1000/60/60/24)<2){
			 		$("#enddate").addClass("onFormError");
     				$("#errorMessage").css({"display": ""});
  					var str="<p>入住香港,澳门酒店必须提前3天预订。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
			 		return;
  					}else{
  						$("#enddate").removeClass("onFormError");
  						$("#errorMessage").css({"display": "none"});
  					}
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				if (parseInt((sd-nowdate)/1000/60/60/24)>60){
			 		$("#enddate").addClass("onFormError");
					$("#errorMessage").css({"display": ""});
  					var str="<p>目前只能提供60天之内的酒店预订服务</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
     				return;
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
			 	if (parseInt((ed-sd)/1000/60/60/24)<0){
			 		$("#enddate").addClass("onFormError");
					$("#errorMessage").css({"display": ""});
  					var str="<p>离店日期必须在入住日期之后一天。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
     				return;
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				
			 	if($("#date").val()==$("#enddate").val()){
			 		$("#enddate").addClass("onFormError");
			 		$("#errorMessage").css({"display": ""});
  					var str="<p>入住时间不能和离店时间为同一天。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
			 		return;
			 	}else{
			 		$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				if (parseInt(Math.abs(ed-sd)/1000/60/60/24)>14){
  					$("#enddate").addClass("onFormError");
  					$("#errorMessage").css({"display": ""});
  					var str="<p>只能选择14天内的酒店。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
     			return; 
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
			 	
			 	
			 	
			 		
			 	
			 	if($("#hotel2").val()=="请输入酒店名称"){
			 		$("#hotel2").val("");
			 	}
			 	saveCitytoCookie();
			 	$("#form1").submit(); 
			 }

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }

        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
  function saveCitytoCookie(){
       var options = { expires: 10, path: '/' };
       $.cookie('Name_firstleaveCity', null);
       $.cookie('firstleaveCity', null);
       $.cookie('Name_firstleaveCity', $('#Name_firstleaveCity').val(),options);
       $.cookie('firstleaveCity', $('#firstleaveCity').val(),options);
  }

$(function () {
 		var cityid = $.cookie('firstleaveCity');
		var cityname = $.cookie('Name_firstleaveCity');
	    if(cityid!= "" && cityid!=null && cityid!="null"){
			$("#Name_firstleaveCity").val(cityname);
			$("#firstleaveCity").val(cityid);
		}
		$(".selects li:first").addClass("current");
		$(".selects li").mouseover(function(){
		$(".selects li").removeClass("current");
		$(this).addClass("current");
		});
});
function validateDate(){
				var st=$("#date").val().replace("-","/").replace("-","/");
  				var et=$("#enddate").val().replace("-","/").replace("-","/");
  
 				var sd=new Date(Date.parse(st));
  				var ed=new Date(Date.parse(et));
  				var nowdate=new Date();
			 	if (parseInt((ed-sd)/1000/60/60/24)<0){
			 		$("#enddate").addClass("onFormError");
					$("#errorMessage").css({"display": ""});
  					var str="<p>离店日期必须在入住日期之后一天。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
     				return;
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				
			 	if($("#date").val()==$("#enddate").val()){
			 		$("#enddate").addClass("onFormError");
			 		$("#errorMessage").css({"display": ""});
  					var str="<p>入住时间不能和离店时间为同一天。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
			 		return;
			 	}else{
			 		$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				if (parseInt((sd-nowdate)/1000/60/60/24)>60){
			 		$("#enddate").addClass("onFormError");
					$("#errorMessage").css({"display": ""});
  					var str="<p>目前只能提供60天之内的酒店预订服务</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
     				return;
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				if (parseInt(Math.abs(ed-sd)/1000/60/60/24)>14){
  					$("#enddate").addClass("onFormError");
  					$("#errorMessage").css({"display": ""});
  					var str="<p>只能选择14天内的酒店，如需预订长住房，请致电12580。</p><div class=\"inArr\"></div>";
  					$("#errorContent").html(str);
     			return; 
  				}else{
  					$("#enddate").removeClass("onFormError");
  					$("#errorMessage").css({"display": "none"});
  				}
  				
			 	var myDate = new Date(); 
			 	
				
}
function checkBusiness(){
$("#businessvalue").val("");
checkNotNull();
}	
function checkZone(){
$("#zonevalue").val("");
checkNotNull();
}	 
function formSubmit(){
				$("#pricevalue").val("-1");
				$("#starvalue").val("44,46,42,43,41,40,400");
				$("#stylevalue").val("-1");
				$("#othervalue").val("-1");
				$("#businessvalue").val("");
				$("#zonevalue").val("");
				$("#pages").val("1");
				$("#orderby").val("12580");
				checkNotNull();
}
function checkNotNullByStar(orderby){
				$("#isOrderBy").val("true");
				$("#orderby").val(orderby);
			 	checkNotNull();
}
function setPriceLevel(priceLevel){
				$("#pricevalue").val(priceLevel);
			 	checkNotNull();
}
function setStarLevel(starlv){
				$("#starvalue").val(starlv);
			 	checkNotNull();
}
function setHotelStyle(style){
				$("#stylevalue").val(style);
			 	checkNotNull();
}
function setOtherStyle(style){
				$("#othervalue").val(style);
			 	checkNotNull();
}

function checkSelectCount(){
var tempCount=0;

var tempObject=$("input[name=businessinfo]");
var tempSize=tempObject.length;
var chestr="";
		for (i=0; i<tempSize; i++)
    	{
    	
        if (tempObject[i].checked == true) {
        tempCount = tempCount+1;
        chestr+=tempObject[i].value+","; 
        }
        
   		}
   		if(tempCount>2){
   			for(i=0;i<tempSize;i++){
   			if(tempObject[i].checked!=true){
   			tempObject[i].disabled=true;
   			}
   			}
        }else{
        	for(i=0;i<tempSize;i++){
   			tempObject[i].disabled=false;
   			}
        }
        $("#businessvalue").val(chestr);
        $("#zonevalue").val("-1");
}

function checkSelectZoneCount(){
var tempCount=0;

var tempObject=$("input[name=zoneinfo]");
var tempSize=tempObject.length;
var chestr="";
		for (i=0; i<tempSize; i++)
    	{
        if (tempObject[i].checked == true) {
        tempCount = tempCount+1;
        chestr+=tempObject[i].value+","; 
        }
        }
       if(tempCount>2){
   			for(i=0;i<tempSize;i++){
   			if(tempObject[i].checked!=true){
   			tempObject[i].disabled=true;
   			}
   			}
        }else{
        	for(i=0;i<tempSize;i++){
   			tempObject[i].disabled=false;
   			}
        }
   		$("#zonevalue").val(chestr);
        $("#businessvalue").val("-1");
   		
}
function checkCity(){
if($("#Name_firstleaveCity").val()=="全拼/简拼/汉字"){
$("#Name_firstleaveCity").val("");
}
$("#Name_firstleaveCity").removeClass("onFormError");
$("#errorMessageCity").css({"display": "none"});
}
 function ShowHtmlString()
{
	var strHtml = "<div style='color: #000; padding:10px; margin-top:12px; text-align:center;font-size:14px'><span style:=' height:50px'>非常歉意的告知您，该房型已售空，您可以选择其他房型或改订其他酒店。</span><br/><br/> <div style='width:80px;margin:0 auto; background:#0099CC; color:#FFFFFF; font-size:12px; padding:5px; border:1px #006699 solid;cursor:pointer' onclick='javascript:window.location.reload();' >我知道了</div>";
	var pop=new Popup({ contentType:2,isReloadOnClose:false,width:500,height:100});
	pop.setContent("contentHtml",strHtml);
	pop.setContent("title","信息提示");
	pop.build();
	pop.show();
}
function checkDate(){
	validateDate();
}

function closeEndDate(){
	$("#ui-datepicker1-div").css({"display": "none"});
}

function checkEndDate(){
	$("#enddate").focus();
}

function hidev(idw) {
	$("#"+idw).css({"display": "none"});
}
function showv(idw) {
	$("#"+idw).css({"display": "block"});
	$("#"+idw).css({"zIndex": "2"});
}
function setInputValueHotel(cityname){
	var code = GetCityCodeByNameHotel(cityname);

	if(!(code==null||code=='')){
		$("#firstleaveCity").val(code);
	}
}
//dataIdType: 0-出发城市，1-到达城市
function GetCityCodeByNameHotel(cityname) {    
    for (var i = 0; i < citys.length; i++) {
        if (citys[i][0].toLowerCase() == cityname.toLowerCase() || citys[i][1] == cityname || citys[i][3].toLowerCase() == cityname.toLowerCase()|| citys[i][2].toLowerCase() == cityname.toLowerCase())
        
            return citys[i][0];
    }
    return null;
}